home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmAuthors
- BorderStyle = 1 'Fixed Single
- Caption = "Authors"
- ClientHeight = 2625
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 4680
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2625
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Begin VB.Data datAuthors
- Caption = "Data1"
- Connect = "Access"
- DatabaseName = "C:\VBDB\Working\Biblio.mdb"
- DefaultCursorType= 0 'DefaultCursor
- DefaultType = 2 'UseODBC
- Exclusive = 0 'False
- Height = 300
- Left = 2520
- Options = 0
- ReadOnly = 0 'False
- RecordsetType = 1 'Dynaset
- RecordSource = "SELECT * FROM Authors ORDER BY Author"
- Top = 120
- Visible = 0 'False
- Width = 1980
- End
- Begin VB.CommandButton cmdDone
- Caption = "Do&ne"
- Height = 375
- Left = 3240
- TabIndex = 13
- TabStop = 0 'False
- Top = 2160
- Width = 1215
- End
- Begin VB.CommandButton cmdDelete
- Caption = "&Delete"
- Height = 375
- Left = 1680
- TabIndex = 12
- TabStop = 0 'False
- Top = 2160
- Width = 1215
- End
- Begin VB.CommandButton cmdEdit
- Caption = "&Edit"
- Height = 375
- Left = 120
- TabIndex = 11
- TabStop = 0 'False
- Top = 2160
- Width = 1215
- End
- Begin VB.CommandButton cmdCancel
- Caption = "&Cancel"
- Height = 375
- Left = 3240
- TabIndex = 10
- TabStop = 0 'False
- Top = 1680
- Width = 1215
- End
- Begin VB.CommandButton cmdSave
- Caption = "&Save"
- Height = 375
- Left = 1680
- TabIndex = 9
- TabStop = 0 'False
- Top = 1680
- Width = 1215
- End
- Begin VB.CommandButton cmdAddNew
- Caption = "&Add New"
- Height = 375
- Left = 120
- TabIndex = 8
- TabStop = 0 'False
- Top = 1680
- Width = 1215
- End
- Begin VB.CommandButton cmdNext
- Caption = "Next =>"
- Height = 255
- Left = 2520
- TabIndex = 7
- TabStop = 0 'False
- Top = 1320
- Width = 1215
- End
- Begin VB.CommandButton cmdPrevious
- Caption = "<= Previous"
- Height = 255
- Left = 1080
- TabIndex = 6
- TabStop = 0 'False
- Top = 1320
- Width = 1215
- End
- Begin VB.TextBox txtYearBorn
- DataField = "Year Born"
- DataSource = "datAuthors"
- Height = 285
- Left = 1200
- Locked = -1 'True
- TabIndex = 2
- Text = "Text3"
- Top = 840
- Width = 1215
- End
- Begin VB.TextBox txtAuthor
- DataField = "Author"
- DataSource = "datAuthors"
- Height = 285
- Left = 1200
- Locked = -1 'True
- TabIndex = 1
- Text = "Text2"
- Top = 480
- Width = 3375
- End
- Begin VB.TextBox txtAuthorID
- DataField = "Au_ID"
- DataSource = "datAuthors"
- Height = 285
- Left = 1200
- Locked = -1 'True
- TabIndex = 3
- TabStop = 0 'False
- Text = "Text1"
- Top = 120
- Width = 1215
- End
- Begin VB.Label Label3
- Caption = "Year Born"
- Height = 255
- Left = 120
- TabIndex = 5
- Top = 840
- Width = 1215
- End
- Begin VB.Label Label2
- Caption = "Author Name"
- Height = 255
- Left = 120
- TabIndex = 4
- Top = 480
- Width = 1215
- End
- Begin VB.Label Label1
- Caption = "Author ID"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1215
- End
- Attribute VB_Name = "frmAuthors"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub cmdAddNew_Click()
- Call SetState("Add")
- End Sub
- Private Sub cmdCancel_Click()
- Call SetState("View")
- End Sub
- Private Sub cmdDelete_Click()
- Dim Response As Integer
- Response = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion + vbDefaultButton2, "Delete")
- If Response = vbNo Then
- Exit Sub
- End If
- End Sub
- Private Sub cmdEdit_Click()
- Call SetState("Edit")
- End Sub
- Private Sub cmdNext_Click()
- datAuthors.Recordset.MoveNext
- If datAuthors.Recordset.EOF Then
- Beep
- datAuthors.Recordset.MoveLast
- End If
- End Sub
- Private Sub cmdPrevious_Click()
- datAuthors.Recordset.MovePrevious
- If datAuthors.Recordset.BOF Then
- Beep
- datAuthors.Recordset.MoveFirst
- End If
- End Sub
- Private Sub cmdSave_Click()
- MsgBox "Record saved.", vbOKOnly + vbInformation, "Save"
- Call SetState("View")
- End Sub
- Private Sub SetState(AppState As String)
- Select Case AppState
- Case "View"
- txtAuthorID.BackColor = vbWhite
- txtAuthor.Locked = True
- txtYearBorn.Locked = True
- cmdPrevious.Enabled = True
- cmdNext.Enabled = True
- cmdAddNew.Enabled = True
- cmdSave.Enabled = False
- cmdCancel.Enabled = False
- cmdEdit.Enabled = True
- cmdDelete.Enabled = True
- cmdDone.Enabled = True
- txtAuthor.SetFocus
- Case "Add", "Edit"
- txtAuthorID.BackColor = vbRed
- txtAuthor.Locked = False
- txtYearBorn.Locked = False
- cmdPrevious.Enabled = False
- cmdNext.Enabled = False
- cmdAddNew.Enabled = False
- cmdSave.Enabled = True
- cmdCancel.Enabled = True
- cmdEdit.Enabled = False
- cmdDelete.Enabled = False
- cmdDone.Enabled = False
- txtAuthor.SetFocus
- End Select
- End Sub
- Private Sub Form_Activate()
- Call SetState("View")
- End Sub
- Private Sub txtYearBorn_KeyPress(KeyAscii As Integer)
- If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Or KeyAscii = vbKeyBack Then
- Exit Sub
- Beep
- KeyAscii = 0
- End If
- End Sub
-